Allocate separate vm areas for rx and tx rings in netback
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 8 Dec 2005 15:58:41 +0000 (16:58 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 8 Dec 2005 15:58:41 +0000 (16:58 +0100)
driver as part of preparation for ia64 support.

Signed-off-by: Dan Magenheimer <dan.magenheimer@hp.com>
linux-2.6-xen-sparse/drivers/xen/netback/common.h
linux-2.6-xen-sparse/drivers/xen/netback/interface.c

index f1d4533d98b0f1f5dc5553a4221cc959923117f6..c2789562795da5ab8c1c6eeaa9ea9d1e5c572287 100644 (file)
@@ -55,7 +55,8 @@ typedef struct netif_st {
        /* The shared rings and indexes. */
        netif_tx_back_ring_t tx;
        netif_rx_back_ring_t rx;
-       struct vm_struct *comms_area;
+       struct vm_struct *tx_comms_area;
+       struct vm_struct *rx_comms_area;
 
        /* Allow netif_be_start_xmit() to peek ahead in the rx request ring. */
        RING_IDX rx_req_cons_peek;
index 23661ababce5ef882ddc73539e84050795904ccf..9e336db31c9a0aac4737c852f42ccff1014caa6b 100644 (file)
@@ -117,14 +117,14 @@ static int map_frontend_pages(
        struct gnttab_map_grant_ref op;
        int ret;
 
-       op.host_addr = (unsigned long)netif->comms_area->addr;
+       op.host_addr = (unsigned long)netif->tx_comms_area->addr;
        op.flags     = GNTMAP_host_map;
        op.ref       = tx_ring_ref;
        op.dom       = netif->domid;
     
-       lock_vm_area(netif->comms_area);
+       lock_vm_area(netif->tx_comms_area);
        ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-       unlock_vm_area(netif->comms_area);
+       unlock_vm_area(netif->tx_comms_area);
        BUG_ON(ret);
 
        if (op.status) { 
@@ -135,14 +135,14 @@ static int map_frontend_pages(
        netif->tx_shmem_ref    = tx_ring_ref;
        netif->tx_shmem_handle = op.handle;
 
-       op.host_addr = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
+       op.host_addr = (unsigned long)netif->rx_comms_area->addr;
        op.flags     = GNTMAP_host_map;
        op.ref       = rx_ring_ref;
        op.dom       = netif->domid;
 
-       lock_vm_area(netif->comms_area);
+       lock_vm_area(netif->rx_comms_area);
        ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-       unlock_vm_area(netif->comms_area);
+       unlock_vm_area(netif->rx_comms_area);
        BUG_ON(ret);
 
        if (op.status) {
@@ -161,22 +161,22 @@ static void unmap_frontend_pages(netif_t *netif)
        struct gnttab_unmap_grant_ref op;
        int ret;
 
-       op.host_addr    = (unsigned long)netif->comms_area->addr;
+       op.host_addr    = (unsigned long)netif->tx_comms_area->addr;
        op.handle       = netif->tx_shmem_handle;
        op.dev_bus_addr = 0;
 
-       lock_vm_area(netif->comms_area);
+       lock_vm_area(netif->tx_comms_area);
        ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-       unlock_vm_area(netif->comms_area);
+       unlock_vm_area(netif->tx_comms_area);
        BUG_ON(ret);
 
-       op.host_addr    = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
+       op.host_addr    = (unsigned long)netif->rx_comms_area->addr;
        op.handle       = netif->rx_shmem_handle;
        op.dev_bus_addr = 0;
 
-       lock_vm_area(netif->comms_area);
+       lock_vm_area(netif->rx_comms_area);
        ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-       unlock_vm_area(netif->comms_area);
+       unlock_vm_area(netif->rx_comms_area);
        BUG_ON(ret);
 }
 
@@ -195,20 +195,23 @@ int netif_map(netif_t *netif, unsigned long tx_ring_ref,
        if (netif->irq)
                return 0;
 
-       netif->comms_area = alloc_vm_area(2*PAGE_SIZE);
-       if (netif->comms_area == NULL)
+       netif->tx_comms_area = alloc_vm_area(PAGE_SIZE);
+       netif->rx_comms_area = alloc_vm_area(PAGE_SIZE);
+       if (netif->tx_comms_area == NULL || netif->rx_comms_area == NULL)
                return -ENOMEM;
 
        err = map_frontend_pages(netif, tx_ring_ref, rx_ring_ref);
        if (err) {
-               free_vm_area(netif->comms_area);
+               free_vm_area(netif->tx_comms_area);
+               free_vm_area(netif->rx_comms_area);
                return err;
        }
 
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                unmap_frontend_pages(netif);
-               free_vm_area(netif->comms_area);
+               free_vm_area(netif->tx_comms_area);
+               free_vm_area(netif->rx_comms_area);
                return err;
        }
 
@@ -218,11 +221,11 @@ int netif_map(netif_t *netif, unsigned long tx_ring_ref,
                netif->evtchn, netif_be_int, 0, netif->dev->name, netif);
        disable_irq(netif->irq);
 
-       txs = (netif_tx_sring_t *)netif->comms_area->addr;
+       txs = (netif_tx_sring_t *)netif->tx_comms_area->addr;
        BACK_RING_INIT(&netif->tx, txs, PAGE_SIZE);
 
        rxs = (netif_rx_sring_t *)
-               ((char *)netif->comms_area->addr + PAGE_SIZE);
+               ((char *)netif->rx_comms_area->addr);
        BACK_RING_INIT(&netif->rx, rxs, PAGE_SIZE);
 
        netif->rx_req_cons_peek = 0;
@@ -255,7 +258,8 @@ static void free_netif_callback(void *arg)
 
        if (netif->tx.sring) {
                unmap_frontend_pages(netif);
-               free_vm_area(netif->comms_area);
+               free_vm_area(netif->tx_comms_area);
+               free_vm_area(netif->rx_comms_area);
        }
 
        free_netdev(netif->dev);